import 'package:boss/models/store_message.dart';
import 'package:boss/models/store_type.dart';
import 'package:boss/provider/store_message_provider.dart';
import 'package:boss/ui/page/pickerAddress/picker_address_page.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:provider/provider.dart';

class EditStoreMessageProvider extends ChangeNotifier {
  StoreMessage storeMessage;

  String get address => storeMessage.address;

  EditStoreMessageProvider() {
    var storeMessageProvider = Provider.of<StoreMessageProvider>(
      GlobalPageContext.instance.context,
      listen: false,
    );

    storeMessage = StoreMessage.fromJson(storeMessageProvider.storeMessage.toJson());
  }

  setStoreType(StoreType value) {
    storeMessage.storeTypeName = value.storeTypeName;
    storeMessage.storeTypeId = value.storeTypeId;
    notifyListeners();
  }

  void setStoreAddress(PCDHData data) {
    storeMessage.province = data.provinces;
    storeMessage.provinceCode = data.provincesCode;
    storeMessage.city = data.city;
    storeMessage.cityCode = data.cityCode;
    storeMessage.district = data.district;
    storeMessage.districtCode = data.districtCode;
    storeMessage.addressDetail = data.address;
    storeMessage.houseNumber = data.houseNumber;
    storeMessage.latitude = data.latitude.toString();
    storeMessage.longitude = data.longitude.toString();
    notifyListeners();
  }
}
